<template>
    <view class="navigation">
        <eui-navbar ref="EuiNavBar" title="商品信息查询" color="#000000" backgroundColor="#FFFFFF" :storeName="sUserStoreName"
            :storeId="sUserStore" @onClickStore="clickStore" />
        <view class="top-view">
            <eui-search-bar ref="RdsSearchBar" v-model="searchText" placeholder="请输入关键字、条码、编码、plu码、拼音码" leftIcon="icon-saoyisao"
                @confirm="searchConfirm" @leftIconClick="scanCode" radius="30" :showFilter="true">
                <template v-slot:searchFields>
                    <view class="search-fields">
                        <eui-card-input v-model="searchData.effect_dt" title="促销生效日期" placeholder="请选择生效日期" type="date"
                            :displayable="displayable" />
                        <view class="bottom flex-1 flex">
                            <eui-button type="max2" title="重置" singleTag="reset" @buttonClick="confirm"
                                maxWidth="300"></eui-button>
                            <eui-button type="max" title="确定" singleTag="fix" @buttonClick="confirm"
                                maxWidth="300"></eui-button>
                        </view>
                    </view>
                </template>
            </eui-search-bar>
        </view>
        <eui-card title="基础信息" hPadding="28" :showTitleLine="showBasic" vPadding="20">
            <template v-slot:extra>
                <view class="extra-view" @click="changeBasicStatus">
                    <eui-uicons :type="showBasic ? 'up' : 'down'" size="32" />
                </view>
            </template>
            <template v-if="showBasic && gdsData.c_gcode">
                <view style="padding: 20rpx 28rpx 0;">
                    <text class="goods-name-title">[{{ gdsData.c_gcode }}]{{ gdsData.c_name }}</text>
                    <view><text class="goods-barcode-text">{{ gdsData.c_barcode }}</text></view>
                    <view class="item-view">
                        <eui-text title="部门" :value="gdsData.c_adno" :name="getName('rdsDeparts', gdsData.c_adno)"
                            :titleStyle="baseDetail" :valueStyle="baseDetail" type="titlename2" />
                        <eui-text title="plu码" :value="gdsData.c_pluno" :titleStyle="baseDetail" :valueStyle="baseDetail"
                            type="name2" />
                        <eui-text title="品类" :value="gdsData.c_ccode" :name="getName('rdsGdsclasses', gdsData.c_ccode)"
                            :titleStyle="baseDetail" :valueStyle="baseDetail" type="titlename2" />
                        <eui-text title="品牌" :value="gdsData.c_bcode" :name="getName('rdsBrands', gdsData.c_bcode)"
                            :titleStyle="baseDetail" :valueStyle="baseDetail" type="titlename2" />
                    </view>
                    <view class="goods-detail-view" style="">
                        <eui-text title="规格/单位" :value="gdsData.c_model" :name="gdsData.c_basic_unit"
                            :valueStyle="showRightStyle" type="slash2" />
                        <eui-text title="保质期/单位"
                            :value="(gdsData.c_od_day ? gdsData.c_od_day + '/' : '') + getDictionName('保质期单位', gdsData.c_od_unit)"
                            :valueStyle="showRightStyle" type="name2"/>
                    </view>
                </view>
            </template>
            <view v-if="!gdsData.c_gcode">
                <image src="@/static/img/no_data.png" mode="aspectFit" class="image-min" />
                <view class="no-data-text">暂无数据</view>
            </view>
        </eui-card>
        <view class="tab-wrapper">
            <eui-tab :spaceLeft="spaceLeft" :value="industryTabIndex" :iconchange="iconchange" :tabs="industryTabs"
                :isScroll="true" @change="tabChange" @click="iconsClick" showBadge="true"></eui-tab>
            <view v-show="industryTabIndex == 0" class="list-container">
                <scroll-view :scroll-top="0" scroll-y="true" class="list-scroll"
                    :style="{ height: listHeight + 'rpx' }">
                    <view class="temp-view" />
                    <view v-for="(item, index) in gdsstorePriceData" :key="index" class="goods-detail-view">
                        <eui-text title="零售价" :value="getNumValue(item.c_price)" :valueStyle="showRightStyle"
                            type="name2" />
                        <eui-text title="会员价" :value="getNumValue(item.c_price_mem)" :valueStyle="showRightStyle"
                            type="name2" />
                        <eui-text title="批发价" :value="getNumValue(item.c_wprice)" :valueStyle="showRightStyle"
                            type="name2" />
                        <eui-text title="促销价" :value="getNumValue(item.c_price_disc)" :valueStyle="showRightStyle"
                            type="name2" />
                        <eui-text title="成本价" :value="getNumValue(item.c_pt_cost)" :valueStyle="showRightStyle"
                                type="name2" />
                    </view>
                </scroll-view>
            </view>
            <view v-show="industryTabIndex == 1">
                <view v-show="!iconchange">

                </view>
                <view v-show="iconchange">
                    <view class="item-view">
                        <eui-text title="入库总数量" :value="getNumValue(c_n_onway_plus_total, 0)"
                            :valueStyle="showRightStyle" type="name2" />
                        <eui-text title="出库总数量" :value="getNumValue(c_n_onway_minus_total, 0)"
                            :valueStyle="showRightStyle" type="name2" />
                    </view>
                    <view class="list-container">
                        <scroll-view :scroll-top="0" scroll-y="true" class="list-scroll"
                            :style="{ height: listHeight + 'rpx' }">
                            <view class="temp-view" />
                            <view v-for="(item, index) in gdsWnoData" :key="index" class="goods-detail-view">
                                <eui-text title="仓库 " :value="item.c_wno" :name="getName('rdsWnos', item.c_wno)"
                                    valueStyle="textAlign: left; fontWeight: 600" type="titlename2" />
                                <eui-text title="数量" :value="getNumValue(item.c_n, 0)" :valueStyle="showRightStyle"
                                    type="name2" />
                                <eui-text title="成本价" :value="getNumValue(item.c_pt_cost)" :valueStyle="showRightStyle"
                                    type="name2" />
                                <eui-text title="最后入库价" :value="getNumValue(item.c_last_pt_pay)" :valueStyle="showRightStyle"
                                    type="name2" />
                                <eui-text title="本部锁定数量" :value="getNumValue(item.c_n_lock, 0)"
                                    :titleStyle="showTitleValue" :valueStyle="showRightStyle" type="name2" />
                                <eui-text title="订货在途数量" :value="getNumValue(item.c_n_onway_order, 0)"
                                    :titleStyle="showTitleValue" :valueStyle="showRightStyle" type="name2" />
                                <eui-text title="退货在途数量" :value="getNumValue(item.c_n_onway_ret, 0)"
                                    :titleStyle="showTitleValue" :valueStyle="showRightStyle" type="name2" />
                                <eui-text title="配送在途数量" :value="getNumValue(item.c_n_onway_dc, 0)"
                                    :titleStyle="showTitleValue" :valueStyle="showRightStyle" type="name2" />
                                <eui-text title="退配在途数量" :value="getNumValue(item.c_n_onway_rd, 0)"
                                    :titleStyle="showTitleValue" :valueStyle="showRightStyle" type="name2" />
                                <eui-text title="店间调拨在途数量" :value="getNumValue(item.c_n_onway_ac, 0)"
                                    :titleStyle="showTitleValue" :valueStyle="showRightStyle" type="name2" />
                                <eui-text title="入库在途总数量" :value="getNumValue(item.c_n_onway_plus, 0)"
                                    :titleStyle="showTitleValue" :valueStyle="showRightStyle" type="name2" />
                                <eui-text title="出库在途总数量" :value="getNumValue(item.c_n_onway_minus, 0)"
                                    :titleStyle="showTitleValue" :valueStyle="showRightStyle" type="name2" />
                            </view>
                        </scroll-view>
                    </view>
                </view>
            </view>
            <view v-show="industryTabIndex == 2" class="list-container">
                <scroll-view :scroll-top="0" scroll-y="true" class="list-scroll"
                    :style="{ height: listHeight + 'rpx' }">
                    <view class="temp-view" />
                    <view v-for="(item, index) in gdsprvData" :key="index">
                        <view class="item-view">
                            <eui-text title="主供应商" :value="item.c_provider"
                                :name="getName('rdsProviders', item.c_provider)" cWidth="width: 100%"
                                type="titlename2" />
                            <eui-text title="合同号" :value="item.c_con_no" cWidth="width: 100%" type="name2" />
                            <eui-text title="越库类型" :value="getDictionName('越库类型', item.c_s_mode)" type="name2" />
                            <eui-text title="物流模式" :value="getDictionName('物流模式', item.c_d_type)" type="name2" />
                            <eui-text title="是否可退货" :value="getDictionName('是非', item.c_can_return)" type="name2" />
                            <eui-text title="配送中心" :value="getName('rdsStores', item.c_dc_store_id)" type="name2" />
                        </view>
                        <view class="goods-detail-view">
                            <eui-text title="最小订量" :value="getNumValue(item.c_min_order_n)" :valueStyle="showRightStyle"
                                type="name2" />
                            <eui-text title="采购进价" :value="getNumValue(item.c_pt_in)" :valueStyle="showRightStyle"
                                type="name2" />
                            <eui-text title="结算进价" :value="getNumValue(item.c_pt_in)" :valueStyle="showRightStyle"
                                type="name2" />
                        </view>
                    </view>
                </scroll-view>
            </view>
            <view v-show="industryTabIndex == 3" class="list-container">
                <scroll-view :scroll-top="0" scroll-y="true" class="list-scroll"
                    :style="{ height: listHeight + 'rpx' }">
                    <view class="temp-view" />
                    <view v-for="(item, index) in gdsstoreSalesData" :key="index" class="goods-detail-view">
                        <eui-text title="截止昨日本周 " :value="getNumValue(item.c_week0)" :titleStyle="showTitleValue"
                            :valueStyle="showRightStyle" type="name2" />
                        <eui-text title="截止昨日本月" :value="getNumValue(item.c_month0)" :titleStyle="showTitleValue"
                            :valueStyle="showRightStyle" type="name2" />
                        <eui-text title="上周销量" :value="getNumValue(item.c_week1)" :valueStyle="showRightStyle"
                            type="name2" />
                        <eui-text title="上周销售额" :value="getNumValue(item.c_week1_sale)" :valueStyle="showRightStyle"
                            type="name2" />

                        <eui-text title="上月销量" :value="getNumValue(item.c_month1)" :valueStyle="showRightStyle"
                            type="name2" />
                        <eui-text title="上月销售额" :value="getNumValue(item.c_month1_sale)" :valueStyle="showRightStyle"
                            type="name2" />

                        <eui-text title="前二周销量" :value="getNumValue(item.c_week2)" :valueStyle="showRightStyle"
                            type="name2" />
                        <eui-text title="前二周销售额" :value="getNumValue(item.c_week2_sale)" :valueStyle="showRightStyle"
                            type="name2" />

                        <eui-text title="前两月销量" :value="getNumValue(item.c_month2)" :valueStyle="showRightStyle"
                            type="name2" />
                        <eui-text title="前两月销售额" :value="getNumValue(item.c_month2_sale)" :valueStyle="showRightStyle"
                            type="name2" />

                        <eui-text title="前三周销量" :value="getNumValue(item.c_week3)" :valueStyle="showRightStyle"
                            type="name2" />
                        <eui-text title="前三周销售额" :value="getNumValue(item.c_week3_sale)" :valueStyle="showRightStyle"
                            type="name2" />

                        <eui-text title="前三月销量" :value="getNumValue(item.c_month3)" :valueStyle="showRightStyle"
                            type="name2" />
                        <eui-text title="前三月销售额" :value="getNumValue(item.c_month3_sale)" :valueStyle="showRightStyle"
                            type="name2" />

                        <eui-text title="前四周销量" :value="getNumValue(item.c_week4)" :valueStyle="showRightStyle"
                            type="name2" />
                        <eui-text title="前四周销售额" :value="getNumValue(item.c_week4_sale)" :valueStyle="showRightStyle"
                            type="name2" />
                    </view>
                </scroll-view>
            </view>
            <view v-show="industryTabIndex == 4" class="list-container">
                <scroll-view :scroll-top="0" scroll-y="true" class="list-scroll"
                    :style="{ height: listHeight + 'rpx' }">
                    <view class="temp-view" />
                    <view v-for="(item, index) in gdsstoreProData" :key="index">
                        <view class="item-view">
                            <eui-text title="单号" :value="item.c_id" cWidth="width: 100%" type="name2" />
                            <eui-text title="顾客类型" :value="getDictionName('顾客类型', item.c_mem_type)" cWidth="width: 100%"
                                type="name2" />
                            <eui-text title="有效时间"
                                :value="(item.c_sdt ? item.c_sdt.split(' ')[0] : '') + ' ~ ' + (item.c_edt ? item.c_edt.split(' ')[0] : '')"
                                cWidth="width: 100%" type="name2" />
                        </view>
                        <view class="goods-detail-view">
                            <eui-text title="售价" :value="getNumValue(item.c_sale_price)" :valueStyle="showRightStyle"
                                type="name2" />
                            <eui-text title="会员价" :value="getNumValue(item.c_mem_price)" :valueStyle="showRightStyle"
                                type="name2" />
                            <eui-text title="促销价" :value="getNumValue(item.c_price_disc)" :valueStyle="showRightStyle"
                                type="name2" />
                            <eui-text title="促销会员价" :value="getNumValue(item.c_price_mem_disc)"
                                :valueStyle="showRightStyle" type="name2" />
                            <eui-text title="折扣率(%)" :value="getNumValue(item.c_price_rate)"
                                :valueStyle="showRightStyle" type="name2" />
                            <eui-text title="会员折扣率(%)" :value="getNumValue(item.c_price_mem_rate)"
                                :valueStyle="showRightStyle" type="name2" />
                            <eui-text title="折扣额" :value="getNumValue(item.c_amount_disc)" :valueStyle="showRightStyle"
                                type="name2" />
                        </view>
                    </view>
                </scroll-view>
            </view>
        </view>
    </view>
</template>

<script setup type="ts">
import { ref, reactive, onMounted, watch } from 'vue';
import { useMainStore } from "@/store/modules/store";
import { useLoginStore } from "@/store/modules/useLoginStore";
import { validateStores } from '@/hooks/useValidateMethod';
import { getRdsUrl, rdsRequest, } from '@/hooks/rdsServices';
import { init } from '@/hooks/init';
import { getRelatedName, getDictName } from '../components/RelatedName.js';
import service from "@/common/service";
import dateRangUtil from '../../../common/dateRangUtil';
import { onLoad } from "@dcloudio/uni-app";
import Enjoy from "@/common/enjoy";
const mainStore = useMainStore();
const LoginStore = useLoginStore();
const rdsUrl = getRdsUrl();
const showBasic = ref(true);
const sUserStore = ref('');
const sUserStoreName = ref('');
const sUser = ref('');
const searchText = ref('');
const spaceLeft = ref(6);
const height = ref(0);
const displayable = ref(false);
const industryTabs = ref([{ name: '价格', corner: 123 }, { name: '库存', corner: 123, icon: 'settings', defaultIcon: 'list' }, { name: '采购', corner: 123 }, { name: '销售', corner: 123 }, { name: '促销', corner: 123 }]);
const baseDetail = ref('fontSize: 24rpx; lineHeight: 33rpx');
const showTitleValue = ref('white-space: nowrap;overflow: hidden;text-overflow: ellipsis');
const showRightStyle = ref('text-align: right; font-weight: 600;margin-right: 20rpx;');
const industryTabIndex = ref(0);
const storeType = ref('');
const gdsData = ref({});
const gdsstorePriceData = ref([]);//商品价格
const gdsBarcodeData = ref([]);//商品条码
const gdsstoreData = ref([]);//商品分店
const gdsWnoData = ref([]);//库存信息
const gdsprvData = ref([]);//采购信息
const gdsstoreSalesData = ref([]);//销售信息
const gdsstoreProData = ref([]);//促销信息
const c_n_onway_plus_total = ref(0);//入库总数量
const c_n_onway_minus_total = ref(0);//出库总数量
const searchData = ref({
    effect_dt: dateRangUtil.formatDate(new Date(), 'YYYY-MM-DD'),
});
const gcode = ref('');
const iconchange = ref(true);
const listHeight = ref(300);
const mainHeight = ref(300);
const RdsSearchBar = ref(null);


onLoad(async () => {
    await init();
})

watch([showBasic, gdsData, industryTabIndex], ([newShowBasic, newGdsData, newIndustryTabIndex], [oldShowBasic, oldGdsData, oldIndustryTabIndex]) => {
    let _showBasic = newShowBasic;
    let _gdsData = newGdsData;
    if (oldShowBasic !== newShowBasic || oldGdsData !== newGdsData || oldIndustryTabIndex !== newIndustryTabIndex) {
        let mHeight = industryTabIndex.value === 1 ? 341 : 288;
        if (_showBasic && _gdsData.c_gcode) {
            listHeight.value = mainHeight.value - mHeight;
        } else if (industryTabIndex.value === 1) {
            listHeight.value = mainHeight.value - 53;
        } else {
            listHeight.value = mainHeight.value
        }
    }
});

// 获取列表高度
const getListHeight = async () => {
    await uni.getSystemInfo({
        success: function (res) { // res - 各种参数
            let info = uni.createSelectorQuery().select(".list-container");
            info.boundingClientRect(function (data) { //data - 各种参数
                //获取列表高度
                let height = res.windowHeight - data.top;
                //转换rpx
                let finalHeight = (height / (res.windowWidth / 750)) - 37;
                listHeight.value = finalHeight;
                mainHeight.value = finalHeight;
            }).exec()
        }
    });
};

// 点击扫描图标跳转打开摄像头
const scanCode = () => {
    uni.scanCode({
        success: function (res) {
            if (res.result != '' && res.result != undefined && res.result != null) {
                searchText.value = res.result;
                getData();
            }
        },
    });
}

onMounted(async () => {
    setDefault();
    await getListHeight();
})

const setDefault = () => {
    const { loginInfo } = mainStore;
    if (loginInfo.sUserStore == '') {
        uni.navigateTo({
            url: '/pages/RdsViews/modals/store/index',
        });
        return;
    }
    sUserStore.value = loginInfo.sUserStore;
    sUserStoreName.value = loginInfo.sUserStoreName;
    sUser.value = loginInfo.sUser;
}

// 选择框点击事件
const clickStore = () => {
    let parms = Enjoy.GetDialogParms();
    parms.CallBack = SelectionChanged;
    parms.SelectionType = "机构选择";
    parms.SelectedItems = sUserStore.value;
    Enjoy.OpenDialog(parms)
}

const searchConfirm = async (e) => {
    if (!e) {
        return;
    }
    searchText.value = e.value;

    await getData();
}

const SelectionChanged = async (event) => {
    if (event.SelectionType == '机构选择') {
        // 更新机构信息
        sUserStoreName.value = event.BackParms.Value;
        sUserStore.value = event.BackParms.Key;
        const result = await validateStores(
            { fieldName: 'c_store_id', row: gdsData.value, newValue: event.BackParms.Key },
            { ischecklimit: true, firstValueMode: true }
        );
        this.storeType = result.c_type;
        if (['2', '3'].includes(result.c_type)) {
            spaceLeft.value = 6;
            industryTabs.value = ['价格', '库存', '采购', '销售', '促销']
        } else {
            spaceLeft.value = 16;
            industryTabs.value = ['价格', '库存', '采购', '销售']
        }
    }
    if (event.type === 'c_gcode') {
        searchText.value = event.c_gcode;
        await getData();
    }
}

const tabChange = (e) => {
    industryTabIndex.value = e;
}

const iconsClick = () => {
    // iconchange.value = !iconchange.value;
}

const getData = async () => {
    service.enjoyShowLoading('正在加载...');
    const req = {
        WhereList: [
            { c_col: "c_gcode", c_oper: "等于", c_value: searchText.value, c_logic: "而且" },
            { c_col: "c_store_id", c_oper: "等于", c_value: sUserStore.value, c_logic: "而且" },
        ]
    };
    const result = await rdsRequest(rdsUrl.bcApi, '商品信息查询', 'FetchUniversal', req, '');
    if (result.ds.length > 0) {
        gdsData.value = { ...result.ds[0] };
        fetchStorePrice();//价格信息
        fetchBarcode();//条码信息
        fetchPurchase();//采购信息
        fetchRecSales();//销售信息
        fetchGdsWno();//库存信息
        fetchGdsPro();//促销信息
    } else {
        setTimeout(() => {
            uni.navigateTo({
                url: '/pages/RdsViews/modals/gds/index?keyWord=' + searchText.value + '&c_store_id=' + sUserStore.value,
            });
        }, 300);
    }
    service.enjoyHideLoading();
}

// 价格信息
const fetchStorePrice = async () => {
    service.enjoyShowLoading('正在加载...');
    const req = {
        WhereList: [
            { c_col: "c_gcode", c_oper: "等于", c_value: searchText.value, c_logic: "而且" },
            { c_col: "c_store_id", c_oper: "等于", c_value: sUserStore.value, c_logic: "而且" },
        ]
    };
    const result = await rdsRequest(rdsUrl.bcApi, '商品信息查询', 'FetchStorePrice', req, '');
    service.enjoyHideLoading();
    if (result.ds.length > 0) {
        gdsstorePriceData.value = result.ds;
    } else {
        gdsstorePriceData.value = [];
    }
}

// 条码信息
const fetchBarcode = async () => {
    // service.enjoyShowLoading('正在加载...');
    const req = {
        WhereList: [
            { c_col: "c_gcode", c_oper: "等于", c_value: searchText.value, c_logic: "而且" },
            { c_col: "c_store_id", c_oper: "等于", c_value: sUserStore.value, c_logic: "而且" },
        ]
    };
    const result = await rdsRequest(rdsUrl.bcApi, '商品信息查询', 'FetchBarcodeByGYT', req, '');
    // service.enjoyHideLoading();
    if (result.ds.length > 0) {
        gdsBarcodeData.value = result.ds;
    } else {
        gdsBarcodeData.value = [];
    }
}

// 采购信息
const fetchPurchase = async () => {
    // service.enjoyShowLoading('正在加载...');
    const req = {
        WhereList: [
            { c_col: "c_gcode", c_oper: "等于", c_value: searchText.value, c_logic: "而且" },
            { c_col: "c_store_id", c_oper: "等于", c_value: sUserStore.value, c_logic: "而且" },
            { c_col: "c_is_primary", c_oper: "等于", c_value: '1', c_logic: "而且" },
        ]
    };
    const result = await rdsRequest(rdsUrl.bcApi, '商品信息查询', 'FetchPurchase', req, '');
    // service.enjoyHideLoading();
    if (result.ds.length > 0) {
        gdsprvData.value = result.ds;
    } else {
        gdsprvData.value = [];
    }
}

// 销售信息
const fetchRecSales = async () => {
    // service.enjoyShowLoading('正在加载...');
    const req = {
        WhereList: [
            { c_col: "c_gcode", c_oper: "等于", c_value: searchText.value, c_logic: "而且" },
            { c_col: "c_store_id", c_oper: "等于", c_value: sUserStore.value, c_logic: "而且" },
        ]
    };
    const result = await rdsRequest(rdsUrl.scApi, 'SCIC公共服务', 'FetchRecSales', req, '');
    // service.enjoyHideLoading();
    if (result.ds.length > 0) {
        gdsstoreSalesData.value = result.ds;
    } else {
        gdsstoreSalesData.value = [];
    }
}

// 库存信息
const fetchGdsWno = async () => {
    // service.enjoyShowLoading('正在加载...');
    const req = {
        WhereList: [
            { c_col: "c_gcode", c_oper: "等于", c_value: searchText.value, c_logic: "而且" },
            { c_col: "c_store_id", c_oper: "等于", c_value: sUserStore.value, c_logic: "而且" },
        ]
    };
    const result = await rdsRequest(rdsUrl.scApi, 'SCIC公共服务', 'FetchGdsWno', req, '');
    // service.enjoyHideLoading();
    if (result.ds.length > 0) {
        gdsWnoData.value = result.ds;
        c_n_onway_plus_total.value = gdsWnoData.value.reduce((pre, current) => pre + (current.c_n_onway_plus ?? 0), 0);
        c_n_onway_minus_total.value = gdsWnoData.value.reduce((pre, current) => pre + (current.c_n_onway_minus ?? 0), 0);
    } else {
        gdsWnoData.value = [];
        c_n_onway_plus_total.value = 0;
        c_n_onway_minus_total.value = 0;
    }
}

// 促销信息
const fetchGdsPro = async () => {
    // service.enjoyShowLoading('正在加载...');
    const req = {
        WhereList: [
            { c_col: "c_gcode", c_oper: "等于", c_value: searchText.value, c_logic: "而且" },
            { c_col: "c_store_id", c_oper: "等于", c_value: sUserStore.value, c_logic: "而且" },
            { c_col: "effect_dt", c_oper: "大于等于", c_value: searchData.value.effect_dt, c_logic: "而且" },
        ]
    };
    const result = await rdsRequest(rdsUrl.bcApi, '商品可参与促销列表', 'EnjoyQueryList', req, '');
    // service.enjoyHideLoading();
    if (result.ReturnObject.length > 0) {
        gdsstoreProData.value = result.ReturnObject;
    } else {
        gdsstoreProData.value = [];
    }
}

const confirm = (t) => {
    let { singleTag } = t;
    switch (singleTag) {
        case 'reset':
            searchData.value.effect_dt = dateRangUtil.formatDate(new Date(), 'YYYY-MM-DD')
            break;
        case 'fix':
            if (!searchText.value) {
                uni.showToast({
                    duration: 3500,
                    icon: 'none',
                    title: '请输入商品条码、编码',
                    mask: true,
                });
                return;
            }
            fetchGdsPro();
            // 关闭弹出层
            RdsSearchBar.value.closeDrawer();
            break;
    }
}

// 点击下拉框
const changeBasicStatus = () => {
    showBasic.value = !showBasic.value;
}

const getName = (key, value) => {
    return getRelatedName(key, value);
}

const getDictionName = (key, value) => {
    return getDictName(key, value);
}

// 显示数值
const getNumValue = (value, precision = 2) => {
    return value ? parseFloat(value).toFixed(precision) : (0).toFixed(precision)
}
defineExpose({
    SelectionChanged
})
</script>

<style lang="scss" scoped>
@import '../../../main.scss';

::v-deep .uni-card__header .single-title{
    font-weight: normal!important;
}

::v-deep .tab-item:nth-of-type(1){
    padding-left: 20rpx!important;
    margin-left: 0!important;
}

::v-deep .tabs-item:nth-last-child{
    padding: 0rpx!important;
    margin-left: 0!important;
    margin-right: 20rpx!important;
}


::v-deep .list_cell {
   padding: 20rpx 0!important;
   .uni-card__header{
    padding-left: 28rpx;
   }
}

.tab-wrapper{
    padding: 4rpx 28rpx 20rpx;
    background: #fff;
    margin: 20rpx;
    border-radius: 20rpx;
    ::v-deep .rds-tabs{
        border-bottom: 1px solid #eee!important;
        border-radius: 0!important;
    }
    ::v-deep .selectdLine{
        width: 70%!important;
        margin-bottom: 0!important;
        bottom: 2rpx;
    }
}

.navigation {
    display: flex;
    height: 100vh;
    width: 100%;
    flex-direction: column;
    background: #F2F2F2;
}

.top-view {
    width: 100%;
    height: 88rpx;
    background: #FFFFFF;
}

.goods-name-title {
    font-family: $uni-font-family;
    font-weight: $uni-font-weight-level3;
    font-size: $uni-font-size-level1;
    color: $uni-text-color-primary;
    line-height: 45rpx;
    text-align: left;
    font-style: normal;
    margin-top: 20rpx;
}

.goods-barcode-text {
    font-family: $uni-font-family;
    font-weight: $uni-font-weight-level1;
    font-size: $uni-font-size-level5;
    color: $uni-text-color-hint;
    line-height: 33rpx;
    text-align: left;
    font-style: normal;
    margin-top: 4rpx;
}

//内容行
.item-view {
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    align-items: center;
    margin-top: 16rpx;
    row-gap: 8rpx;
}

.goods-detail-view {
    width: 654rpx;
    background: #F9FAFC;
    border-radius: 10rpx;
    margin-top: 15rpx;
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    align-items: center;
    padding: 20rpx 0rpx 20rpx 20rpx;
    box-sizing: border-box;
    row-gap: 12rpx;
}

.extra-view {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 60rpx;
    height: 100%;
}

.list-container {
    width: 100%;
}

.list-scroll {
    height: 600rpx;
    /* 列表容器的初始高度 */
    overflow-y: auto;
}

.temp-view {
    width: 100%;
    height: 1rpx;
}

.search-fields {
    width: 100%;
    background: #FFFFFF;
    position: relative;

    .bottom {
        background: #ffffff;
        border-top: 1rpx solid $uni-line-color;
        display: flex;
        justify-content: center;
        padding: 20rpx;
    }
}

.status-view {
    width: 100%;
    height: 40rpx;
    background: $uni-bg-color-inverse;
}

.image-min {
    width: 100%;
    height: 150rpx;
    opacity: 0.6;
    margin-top: -20rpx;
}

.no-data-text {
    text-align: center;
    color: #cccccc;
    font-size: 26rpx;
    margin-top: -20rpx;
}
</style>
